package com.deyuanyun.pic.ctrl.controller;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.ajax.AjaxSupport;
import com.deyuanyun.pic.ctrl.service.OclDefectRepairMgrService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 外涂层漏损点维修过程查询控制
 *
 * @author hlw
 * @date 2016-06-16
 *
 * History: [修改人][时间][修改描述]
 */
@Controller
@RequestMapping("/corrctrl/repairMgr")
public class OclDefectRepairMgrController {

    @Resource
    private OclDefectRepairMgrService oclDefectRepairMgrService;

    /**
     * 跳转到涂层维修记录详情页面
     *
     * @return
     */
    @RequestMapping("/toRepairWorkRecord.html")
    public ModelAndView toRepairWorkRecord() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/corrctrl/repair/repairWorkRecord");
        return mav;
    }

    /**
     * 根据“漏损点缺陷编号”查询 缺陷点维修节点
     *
     * @param defectId 缺陷点编号
     */
    @RequestMapping(value = "/queryRepairNode.json")
    @ResponseBody
    public void queryRepairNode(String defectId) {
        if (StringUtils.isNullEmpty(defectId)) {
            AjaxSupport.sendFailText("error", "“漏损点缺陷编号”不能为空");
        }
        AjaxSupport.sendSuccessText("success", oclDefectRepairMgrService.queryRepairNode(defectId));
    }

    /**
     * 跳转到统计页面
     *
     * @return
     */
    @RequestMapping("/toStatistics.html")
    public ModelAndView toStatistics() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/corrctrl/repair/repairStatistics");
        return mav;
    }

    /**
     * 缺陷状态统计
     *
     * @param repairTaskId 维修任务编号
     */
    @RequestMapping(value = "/statistics.json")
    @ResponseBody
    public void statistics(String repairTaskId) {
        if (StringUtils.isNullEmpty(repairTaskId)) {
            AjaxSupport.sendFailText("error", "“维修任务编号”不能为空");
        }
        AjaxSupport.sendSuccessText("success", oclDefectRepairMgrService.getDefectStatistics(repairTaskId));
    }

}
